const { Server } = require('ws');
const wss = new Server({ port: 8888 });
// socket套接字，
wss.on('connection', (socket) => {
    // 通过message来监听客户端发送的消息
    socket.on('message', (message) => {
        console.log('message: ',message.toString());
        socket.send(message); //把消息发送给客户端
    });
});